*** Copy thy neighbour: Spatial interdependences in the democracy-repression nexus ***
*** Journal of Human Rights ***
*** Created by Roman-Gabriel Olar on 01/05/2019 ***
*** Last modified on 25/08/2023 ***

***Prepare data for map***
ssc install spmap
ssc install shp2dta
ssc install mif2dta

cd "set own working directory"
**Unpack the cshapes zip file**
shp2dta using cshapes, database(country) coordinates(countryxy) genid(id) gencentroids(c)
use country, clear
spmap using countryxy, id(id)

use "MainData_noresdep.dta", clear
replace ccode=255 if ccode==260
collapse v2x_polyarchy theta_mean, by(ccode)
save macro_small.dta, replace

use country.dta, clear
sort ccode
merge m:m ccode using macro_small.dta
replace theta_mean=0-theta_mean
replace v2x_polyarchy=0-v2x_polyarchy

**Create Figure 1
use country.dta, clear
 spmap v2x_polyarchy using countryxy, id(id) fcolor(Blues) clmethod(quantile) legend(symy(*2) symx(*2) size(*2)) legorder(lohi) title("Democracy in the world, 1947-2007")
 spmap theta_mean using countryxy, id(id) fcolor(Reds) clmethod(quantile) legend(symy(*2) symx(*2) size(*2)) legorder(hilo) title("Repression in the world, 1947-2007")

